package com.dingqb.androidproject.mvp;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.dingqb.androidproject.R;

/**
 * Created by dingqb on 2018/3/30.
 */

public class OprationActivity extends Activity implements View.OnClickListener,Mode {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mvp);
        initView();
    }

    Button btn_add;
    Button btn_update;
    Button btn_delete;

    private void initView() {
        btn_add = findViewById(R.id.btn_add);
        btn_update = findViewById(R.id.btn_update);
        btn_delete = findViewById(R.id.btn_delete);
        btn_add.setOnClickListener(this);
        btn_update.setOnClickListener(this);
        btn_delete.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_add:
                Presenter p=new Presenter(this);
                p.addPresenter("add");
                break;
            case R.id.btn_update:
                break;
            case R.id.btn_delete:
                break;
            default:
                break;
        }
    }

    @Override
    public void add(final String str) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                btn_add.setText(str+"");
            }
        });

    }

    @Override
    public void update(String str) {

    }

    @Override
    public void delete(String str) {

    }
}
